package com.anosine.gpsl.android.ui.activity;

import com.baidu.mapapi.map.BaiduMap;
import com.baidu.mapapi.map.BaiduMapOptions;
import com.baidu.mapapi.map.MapStatus;
import com.baidu.mapapi.map.MapView;
import com.baidu.mapapi.model.LatLng;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
/**
 * @Title: BaseMapActivity
 * @Package com.anosine.gpsl.android.ui.activity
 * @Description: 
 * @author: sunny
 * @date: 2015-11-24
 * @version V1.0
 */
public class BaseMapActivity extends Activity {
	@SuppressWarnings("unused")
	private static final String LTAG = BaseMapActivity.class.getSimpleName();
	private MapView mMapView;
	private BaiduMap mBaiduMap;
	/**
	 * @Title: onCreate(Bundle savedInstanceState)
	 * @Description: 初始化
	 * @param: savedInstanceState
	 * @return: 无
	 * @throws
	 */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		Intent intent = getIntent();
		if (intent.hasExtra("x") && intent.hasExtra("y")) {
			// 当用intent参数时，设置中心点为指定点
			Bundle b = intent.getExtras();
			LatLng p = new LatLng(b.getDouble("y"), b.getDouble("x"));
			mMapView = new MapView(this,
					new BaiduMapOptions().mapStatus(new MapStatus.Builder()
							.target(p).build()));
		} else {
			mMapView = new MapView(this, new BaiduMapOptions());
		}
		setContentView(mMapView);
		mBaiduMap = mMapView.getMap();
	}
	/**
	 * @Title: onPause()
	 * @Description: 暂停
	 * @param: 无
	 * @return: 无
	 * @throws
	 */
	@Override
	protected void onPause() {
		super.onPause();
		// activity 暂停时同时暂停地图控件
		mMapView.onPause();
	}
	/**
	 * @Title: onResume()
	 * @Description: 
	 * @param: 无
	 * @return: 无
	 * @throws
	 */
	@Override
	protected void onResume() {
		super.onResume();
		// activity 恢复时同时恢复地图控件
		mMapView.onResume();
	}
	/**
	 * @Title: onDestroy()
	 * @Description: 销毁
	 * @param: 无
	 * @return: 无
	 * @throws
	 */
	@Override
	protected void onDestroy() {
		super.onDestroy();
		// activity 销毁时同时销毁地图控件
		mMapView.onDestroy();
	}
}
